package net.atomarrow.controllers.converter;

import java.util.Arrays;
import java.util.List;


public class ListConverter implements IConverter {

    @Override
    public boolean canHandle(Class clazz) {
        return List.class.isAssignableFrom(clazz);
    }

    @Override
    public <T> T converter(Object[] values, Class<T> clazz) throws Exception{
        if(values.length>1){
            return (T) Arrays.asList(values);
        }
        String value = values[0].toString();
        if(value.contains(",")){
            return (T) Arrays.asList(value.split(","));
        }
        return (T) Arrays.asList(values);
    }
}
